import request from '@/utils/request'
import config from '@/config'
import { getToken,getCaptchaToken  } from '@/utils/auth'
export function loginByUsername(username, password,captcha) {
  const data = {
    username,
    password,
    captcha
  }
  return request({
    url: config.context + '/api/auth/login',
    method: 'post',
    data,
    headers: {'X-Token':getCaptchaToken()},

  })
}

export function logout(token) {
  const data = {
    token
  }
  return request({
    url: config.context + '/api/auth/logout',
    method: 'post',
    params: data
  })
}

export function getUserInfo() {
  var data = {
  }
  return request({
    url: config.context + '/api/user/getUserInfo',
    method: 'post',
    data,
    // headers: {'X-Token':getToken()}
  })
}

export function getCat() {
  var data = {
  }
  return request({
    url: config.context + '/api/user/getUserInfo',
    method: 'post',
    data,
    // headers: {'X-Token':getToken()}
  })
}

export function getCaptcha() {
  var data = {
    random: Math.random()
  }
  return request({
    url: config.context + '/api/web/common/captcha',
    method: 'get',
    data
  })
}
